package vn.lumi.smarthome.network;

import java.util.ArrayList;

public class CreateScene extends AppMsg{

	//attributes
	private int Scene_id = 0;
	private int[] deviceIDList = null;
	private int[] deviceStateList = null;
	private int[] RGBIDList = null;
	private ArrayList<int[]> RGBStateList = null;
	
	public CreateScene(int uid, int sid, int scene_id, int[] DeviceIDList, int[] DeviceStateList, int[] rgbIDList, ArrayList<int[]> rgbStateList) {
		super(Message.CMD_APP_CREATE_SCENE, uid, sid);
		// TODO Auto-generated constructor stub
		Scene_id = scene_id;
		deviceIDList = DeviceIDList;
		deviceStateList = DeviceStateList;
		RGBIDList = rgbIDList;
		RGBStateList = rgbStateList;
	}

	@Override
	public byte[] generateByteArray() {
		// TODO Auto-generated method stub
		byte[] result = new byte[4 + deviceIDList.length*2 + RGBIDList.length*4];
		result[0] = (byte) this.Cmd_id;
		result[1] = (byte) this.user_id;
		result[2] = (byte) this.session_id;
		result[3] = (byte) this.Scene_id;
		int NumOfDevice = deviceIDList.length;
		for(int i = 0; i<NumOfDevice; i++){
			result[4+2*i] = (byte) deviceIDList[i];
			result[5+2*i] = (byte) deviceStateList[i];
		}
		int startPos = 4+2*NumOfDevice;
		int NumOfRGB = RGBIDList.length;
		for(int i = 0; i<NumOfRGB; i++){
			result[startPos+4*i] = (byte) RGBIDList[i];
			result[startPos+4*i+1] = (byte) RGBStateList.get(i)[0];
			result[startPos+4*i+2] = (byte) RGBStateList.get(i)[1];
			result[startPos+4*i+3] = (byte) RGBStateList.get(i)[2];
		}
		return result;
	}

}
